package com.class04.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

/**
 * @ClassDescription:
 * @JdkVersion: 17
 * @Author: yxy
 * @Created: 2023/11/8 14:06
 */
@Repository
public class StudentDao {
    @Autowired
    private JdbcTemplate jdbcTemplate;
//    private JdbcTemplate jdbcTemplate = new JdbcTemplate();
    public void updateNameById(String name,Integer id){
        String sql = "update students set name = ? where id = ?;";
        int update = jdbcTemplate.update(sql, name, id);
        System.out.println("update = " + update);

    }
    public void updateAgeById(Integer age,Integer id){
        String sql = "update students set age = ? where id = ?;";
        int update = jdbcTemplate.update(sql, age, id);
        System.out.println("update = " + update);

    }
}
